<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<link rel="stylesheet" href="${aier_css_url}social/module/homeside.css" />

<div class="home-side" style="overflow: hidden;">

	<div class="side-nav-top">
		<!-- 普通标签 -->
		<div class="tab-normal">
			<a class="btn" href="${aier_url}${aier_uri}userhomeforums_homeForums${aier_suffix}">
				<em class="icon-1 icon-1-xxs"></em>
				<span>新鲜事</span>
			</a>
		</div>
		
		 <div class="tab-normal">
			<a class="btn" href="${aier_url}${aier_uri}usermessage_userMessage${aier_suffix}">
				<em class="icon-1 icon-1-msg"></em>
				<span>与我相关</span>
			</a>
		</div> 
		<div class="tab-normal">
			<a class="btn" onclick="chumsFresh(1)">
				<em class="icon-1 icon-1-miyou"></em>
				<span>密友圈</span>
			</a>
		</div>


		<div class="tab-normal">
			<a class="btn" href="${aier_url}${aier_uri}userhomeforums_homeFavourite${aier_suffix}">
				<em class="icon-1 icon-1-sc"></em>
				<span>收藏</span>
			</a>
		</div>



	</div>
	
	<!-- 密友
	<div class="side-nav-closefriend">
		
		<div class="side-nav-title">-->
		<!-- 
				<a href="${aier_url}user/userchumscircle.shtml" class="btn-normal-orange">
					<span>管理</span>
				</a>
		</div> 

		<div class="tab-normal">
			<a class="btn" onclick="chumsFresh(1)">
				<em class="icon-1 icon-1-miyou"></em>
				<span>密友</span>
			</a>
		</div>
	</div> -->	

	<!-- 分组阅读 -->
	<div class="side-friendgroup">
		<fieldset class="title-fieldset">
			<legend>分组</legend>
			<a class="btn-guanli btn-normal-orange" href="${aier_url}${aier_uri}usermyfollow${aier_suffix}">
				<span>管理</span>
			</a>
		</fieldset>

		<div class="" id="fGroup"></div>
		<div id="moreList" style="display: none;"></div>
		<div id="levmore" class="more-lev">
			<a class="S_link1" href="javascript:void(0);"
				onclick="infonav_more_down()">展开</a>
		</div>
	</div>

	<!-- 家校联系簿 -->
	<div class="side-nav-closefriend">
		
		<fieldset class="title-fieldset">
			
		</fieldset>

		<div class="tab-normal">
			<a class="btn" href="${aier_url}${aier_uri}userhscb_list${aier_suffix}">
				<em class="icon-1 icon-1-jiaxiao"></em>
				<span>家校联系簿</span>
			</a>
		</div>
	</div>


	<div>
		<fieldset class="title-fieldset"></fieldset>
		<div class="tab-normal">
			<a class="btn"
				href="${aier_url}${aier_uri}lookup_findPeople${aier_suffix}"><em class="forums-ico-5 icon-1 icon-1-zhaoren"></em>
				<span>找人</span></a>
		</div>
		<div class="tab-normal">
			<a class="btn"
				href="${aier_url}${aier_uri}lookup_findSchool${aier_suffix}"><em
				class="forums-ico-5 icon-1 icon-1-zhaoren"></em>
				<span>找学校</span></a>
		</div>
		<div class="tab-normal">
                <a class="btn" 
                href="${aier_url}${aier_uri}lookup_findClass${aier_suffix}"><em 
                class="forums-ico-5 icon-1 icon-1-zhaoren"></em><span>找班级</span></a>
            </div>
	</div>

	<div class="without-icon">
		<fieldset class="title-fieldset">
			<legend>学校</legend>
		</fieldset>
		
		<s:iterator value="schoolList" id="sl">
		<div class="tab-small" title=<s:property value="#sl.name" />>
			<a class="btn" target="_blank" href="${aier_url}school/schoolhome_home${aier_suffix}?sid=<s:property value="#sl.sid"/>"><s:property
					value="#sl.name" /> </a>
					</div>
		</s:iterator>
		

	</div>
	<div class="without-icon">
		<fieldset class="title-fieldset">
			<legend>班级</legend>
		</fieldset>
		
		
			<s:iterator value="classList" id="cl">
			<div class="tab-small" title=<s:property value="#cl.cname" /> >
				<a class="btn" href="${aier_url}classes/classeshome_classHomePage${aier_suffix}?cid=<s:property value="#cl.cid"/>"><s:property
						value="#cl.cname" /> </a>
						</div>
			</s:iterator>
			
		
	</div>
	<div id="createGroupDialog" title="创建分组">

	    <div>
	        <label for="createGroup">创建分组</label>
	        <input type="text" id="groupName">
	    </div>
	
	</div>
</div>

<script type="text/javascript">
    var fgList;
	function infonav_more_down() {
		$("#moreList").show(300);
		$("#levmore")
				.html(
						"<a class='S_link1' href='javascript:void(0);' onclick='infonav_more_up()'>收起</a>");
	}
	function infonav_more_up() {
		$("#moreList").hide(300);
		$("#levmore")
				.html(
						"<a class='S_link1' href='javascript:void(0);' onclick='infonav_more_down()'>展开</a>");
	}
	
	$(document).ready(function() {
		searchFollowGroup();				
	});
	
	// 获取分组列表
	function searchFollowGroup() {
        var fun = function(data) {
            if (data.s == 1) {
                var c = "";
                var m = "";
                fgList = data.fgList;
                for ( var i = 0; i < data.fgList.length; i++) {
                    if (i < 2) {
                        if (data.fgList[i].name == "特别关注") {
                            c += '<div class="tab-normal"><a class="btn" onclick="followFresh('+data.fgList[i].fgid+',1)"><i class="forums-ico-5 icon-1 icon-1-teguan"></i>'
                                    + data.fgList[i].name
                                    + '</a></div>';
                        } else {
                            c += '<div class="tab-normal"><a class="btn" onclick="followFresh('+data.fgList[i].fgid+',1)"><i class="forums-ico-5 icon-1 icon-1-weifen"></i>'
                                    + data.fgList[i].name
                                    + '</a></div>';
                        }
                    } else {
                        if (data.fgList[i].name == "特别关注") {
                            m += '<div class="tab-normal"><a class="btn" onclick="followFresh('+data.fgList[i].fgid+',1)"><i class="forums-ico-5 icon-1 icon-1-teguan"></i>'
                                    + data.fgList[i].name
                                    + '</a></div>';
                        } else {
                            m += '<div class="tab-normal"><a class="btn" onclick="followFresh('+data.fgList[i].fgid+',1)"><i class="forums-ico-5 icon-1 icon-1-weifen"></i>'
                                    + data.fgList[i].name
                                    + '</a></div>';
                        }
                    }
                }
                m += "<div class='more-lev'><a class='S_link1' id='createGroup'>创建新分组</a></div>";
                $("#fGroup").html(c);
                $("#moreList").html(m);
                // 创建分组
                $('#createGroup').click(function() {
                    $('#createGroupDialog').dialog("open");
                });
            }
        };
        exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}usermyfollow_searchFollowGroup${aier_suffix}"),
                fun, {});
	
	}

	

	// 查看密友圈的新鲜事
	function chumsFresh(nowpage) {
	    page = nowpage;
		var fun = function(data) {
			if (data.s == 1) {
			    $("#freshList").html("");
				if (data.freshList != null) {
					appendFresh(data.freshList, data.uid);
				} else {
					$("#freshList").html("您的密友暂时没有什么行动哦");
				}
                // 更新分页显示
                page = data.page;
                toLoadPage(page, page_size, data.page_count, data.count, "page", "chumsFresh", null, null);
                if (data.count == 0) {
                    $("#page").css("display","none");
                } else {
                    $("#page").css("display","block");
                }
			}
		};
		exeAjax(
				ajaxUrl("${aier_url}${aier_urijs}userchumscircle_searchAllFresh${aier_suffix}"),
				fun, {
				    "page":page,
				    "page_size":page_size
				});

	}

	// 查看关注的新鲜事
	function followFresh(fgid,nowpage) {
	    page = nowpage;
		var fun = function(data) {
			if (data.s == 1) {
			    $("#freshList").html("");
				if (data.freshList != null) {
					appendFresh(data.freshList, data.uid);
				} else {
					$("#freshList").html("您的关注暂时没有什么行动哦");
				}
                // 更新分页显示
                page = data.page;
                toLoadPage(page, page_size, data.page_count, data.count, "page", "followFresh", fgid, null);
                if (data.count == 0) {
                    $("#page").css("display","none");
                } else {
                    $("#page").css("display","block");
                }
			}
		};
		exeAjax(
				ajaxUrl("${aier_url}${aier_urijs}usermyfollow_searchFreshByFgid${aier_suffix}"),
				fun, {
					"fgid" : fgid,
					"page": page,
					"page_size":page_size
				});

	}
	
	//   新建分组
	$('#createGroupDialog').dialog({
	    //背景变暗
	    modal: true,
	    autoOpen : false,
	    show : "fade",
	    hide : "fade",
	    width : "300",
	    height : "200",
	    buttons: {
	        "确定": function() {
	            
	            var name = $("#groupName").val();
	            if (isnull(name)) {
	               $().message("请输入分组名！");
	               return;
	            }
	            if (fgList != null && fgList.length > 0) {
	                for (var i = 0; i<fgList.length; i++) {
	                    if (name == fgList[i].name) {
	                        $().message("已存在相同分组！");
	                        return;
	                    }
	                }
	            }
	            var fun=function(data){
	               if(data.s==1){
	                   searchFollowGroup();
	                   $("#groupName").val("");
	                   $('#createGroupDialog').dialog("close");
	               } else if(data.s == 10001){
	                   $().message("已存在相同分组！");
	               } else {
	                   $().message("创建失败，请稍后再试！");
	               }
	           };
	           exeAjax(
	                ajaxUrl("${aier_url}${aier_urijs}usermyfollow_addFollowGroup${aier_suffix}"),
	                fun,{
	                    "name":name
	           });
	
	        },"取消": function() {
	            $( this ).dialog( "close" );
	            $("#groupName").val("");
	        }
	    }
	});
</script>
